#include "SatelliteContent.h"

class GPSSatelliteContent : public SatelliteContent {
public:
    explicit GPSSatelliteContent(QWidget *parent = nullptr) : SatelliteContent(parent) {
        const int maxSat = 32; // GPS 最大卫星数
        QVBoxLayout *layout = new QVBoxLayout(this);

        satComboBox = new QComboBox(this);
        QComboBoxManager::getInstance().setSatComboBox(satComboBox);
        satComboBox = QComboBoxManager::getInstance().getSatComboBox();
        satComboBox->setObjectName("satComboBox");
        satComboBox->addItem("全部");
        satComboBox->hide(); // 隐藏 satComboBox
        layout->addWidget(satComboBox);

        // 创建公共图标对象（优化性能）
        QIcon icon("../config/satellite.png");
        QSize iconSize(16, 16);

        QPushButton *button = new QPushButton("全 部", this);
        button->setProperty("type", "action");  // 用于QSS特殊样式

        connect(button, &QPushButton::clicked, [=]() {
            satComboBox->setCurrentIndex(0);
        });
        layout->addWidget(button);

        for (int i = 0; i < maxSat; i++) {
            QString name = QString("GPS %1").arg(i + 1);
            satComboBox->addItem(name);

            QPushButton *button = new QPushButton(name, this);
            // 设置图标
            button->setIcon(icon);
            button->setIconSize(iconSize);
            button->setProperty("type", "action");  // 用于QSS特殊样式
            button->setProperty("type", "action");  // 用于QSS特殊样式

            connect(button, &QPushButton::clicked, [=]() {
                satComboBox->setCurrentIndex(i + 1);
                qDebug() << "satComboBox clicked " << name;
            });
            layout->addWidget(button);
        }
    }
};